/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
(function($){
    $.fn.extend({
        //plugin name - resizeimg
        resizeimg: function(options) {
            //Settings list and the default values
            var defaults = {
            //                maxWidth: 0,
            //                maxHeight:0
            };
            var options = $.extend(defaults, options);
            //            $.extend(defaults, options);
            
            return this.each(function() {
                
                
                var o = options;
                //Assign current element to variable, in this case is UL element
                var obj = $(this);   
                //Plugin code goes here
                //                var maxWidth = o.maxWidth;
                //                var maxHeight= o.maxHeight;               
                
                var maxWidth = obj.parent().width();
                var maxHeight = obj.parent().height();
                
                var imgWidth = obj.width();
                var imgHeight = obj.height();
                
                
                
                var newHeight = maxHeight;
                var ratio = imgHeight/maxHeight;
                
                if(maxHeight > imgHeight){
                    ratio = maxHeight/imgHeight;
                }
                
                var newWidth = imgWidth/ratio;
                $(this).width(newWidth);
                $(this).height(newHeight);
                obj.css({
                    //                    'visibility':'visible',
                    'height': 'newHeight',
                    'width': 'newWidth'
                });
            });
        }
    });
})(jQuery);

function resizeBackground()
{
    
    var scale=0;
    var stageWidth=$(window).width();
    var newWidth=$(".resizeme").width();
    var stageHeight=$(window).height();
    var newHeight=$(".resizeme").height();

    if( $(window).width() > $(window).height() )
    {
        scale = stageHeight/newHeight;
        scale = stageWidth/newWidth;
    }
    else
    {
        scale = stageWidth/newWidth;
        scale = stageHeight/newHeight;
    }

    newWidth = newWidth*scale;
    newHeight = newHeight*scale;
    $(".resizeme").width(newWidth);
    $(".resizeme").height(newHeight);
}

function getParameter(){
    var args=new Array();
    var query = window.location.search.substring(1);
    
    if(query){
        var parsList=query.split('&');
        for(par in parsList){           
            var parts=parsList[par].split('=');
            args[unescape(parts[0])] = unescape(parts[1]);
        }
    }
    //alert(args['page']);
    return args;
//    alert(query);
}

